package com.edu.springboot_disk_erban.dao;


import com.edu.springboot_disk_erban.entity.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;

@Mapper
@Component("userMapper")
public interface UserDao {
    //增加
    @Insert("insert into user(username,password) values(#{username},#{password}) ")
    int addUser(User user);

    //删
    @Delete("delete from user where userId=#{userId}")
    int deleteById(int userId);

    //改
    @Update("update user set password=#{password} where username=#{username}")
    int update(User user);
    //查  查找所有用户
    @Select("select * from user")
    List<User> findAll();

    //根据用户信息去查找用户
    @Select("select * from user where username=#{username} and password=#{password}")
    User findUser(User user);

    //查找用户是否存在
    @Select("select * from user where username=#{username}")
    User findUserByUserName(String username);

    //查找个人信息

    // 查询个人信息
    @Select("select * from user where username=#{username}")
    User findUserInfo(String username);

    // 修改个人信息
    @Update("update user set email=#{email}, motto=#{motto}, city=#{city},nickname=#{nickname}, gender=#{gender}" +
            " where username=#{username}")
    void editUserInfo(User user);


    // 修改个人信息
    @Update("update user set password=#{password}  where username=#{username}")
    void editPasswd(User user);

}
